package com.huawei.appgallery.foundation.ui.css.adapter;

import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import com.huawei.appgallery.foundation.ui.css.adapter.param.MethodSignature;

public class ImageViewAdapter extends RenderAdapter {
    protected static final CSSPropertyMethod CSS_PROPERTY_METHOD = new CSSPropertyMethod();
    public static final RenderAdapterFactory FACTORY = new RenderAdapterFactory() {
        public RenderAdapter create(View view) {
            return new ImageViewAdapter();
        }
    };

    static class BackgroundTintMethodForImageView extends BackgroundTintMethod {
        private BackgroundTintMethodForImageView() {
        }

        protected Drawable getDrawable(Object obj) {
            Drawable drawable = super.getDrawable(obj);
            if (drawable == null) {
                return ((ImageView) obj).getDrawable();
            }
            return drawable;
        }
    }

    static {
        CSS_PROPERTY_METHOD.inherit(ViewAdapter.CSS_PROPERTY_METHOD);
        CSS_PROPERTY_METHOD.getSignature(CSSPropertyName.BACKGROUND_TINT).setGenerator(new BackgroundTintMethodForImageView());
    }

    public MethodSignature getMethod(String str) {
        return CSS_PROPERTY_METHOD.getSignature(str);
    }
}
